//
//  MenuTbCell.m
//  UIScrollView的快速使用
//
//  Created by hongfei tam on 2019/2/15.
//  Copyright © 2019 YQ05. All rights reserved.
//

#import "MenuTbCell.h"
#import "../MKConstant.h"

@interface MenuTbCell(){
   
    UILabel *label;
}
@end

@implementation MenuTbCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}


// cell = cell 创建 ＋ cell 内容加载: 添加＋内容
+(instancetype)createCellWithTableView:(UITableView*)tableView{
    static NSString *ID = @"youngMenu";
    MenuTbCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
    if (cell == nil) {
        cell = [[MenuTbCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:ID];
    }
    return cell;
}
// 添加
// 1 init 。frame 这个方法才被调用
// 2 addsubview
// 3 view frame
-(void)layoutSubviews{
    
    CGFloat labelX = 10;
    CGFloat labelY = 0;
    CGFloat labelW = UISCREEN_WIDTH - 10*2;
    CGFloat labelH = self.frame.size.height;
    label.frame = CGRectMake(labelX, labelY, labelW, labelH);
    [self addSubview:label];
}
// 内容
-(void)setCellText:(NSString*)str{
    if (label == nil) {
        label = [[UILabel alloc]init];
    }
    label.text = str;
    label.textColor = [UIColor blackColor];
    label.font = [UIFont systemFontOfSize:20];
    label.textAlignment = NSTextAlignmentCenter; //UITextAlignmentCenter 字體居中
}
@end
